package com.bishitest.domain;

import java.math.BigDecimal;
import java.util.List;

/**
 * @author XuFan
 * @create 2025-08-19-18:28
 */
public class OrderList {

    public BigDecimal orderListTotalPrice;

    public boolean totalPriceHasReduce;

    public OrderList(List<OrderListRecord> records, boolean totalPriceHasReduce) {
        this.records = records;
        this.totalPriceHasReduce = totalPriceHasReduce;
        this.setOrderListTotalPrice();
    }

    public List<OrderListRecord> records;

    public void setOrderListTotalPrice () {
        for (OrderListRecord record : this.records) {
            this.orderListTotalPrice = this.orderListTotalPrice == null ? record.recordPrice : this.orderListTotalPrice.add(record.recordPrice);
        }
        if (totalPriceHasReduce && (this.orderListTotalPrice.compareTo(new BigDecimal(100)) >= 0)) this.orderListTotalPrice = this.orderListTotalPrice.add(new BigDecimal(-10));
    }
}
